{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Linux/Ubuntu\n",
    "\n",
    "## 1 What is Linux\n",
    "\n",
    "### 1.1 History of Linux\n",
    "\n",
    "**Unix** was initially designed and implemented at AT&T Bell Labs 1969 by Ken Thompson, Dennis Ritchie, Douglas McIlroy, and\n",
    "Joe Ossanna\n",
    "\n",
    "* First released in 1971 and was written in assembly language\n",
    "\n",
    "* Re-written in C by Dennis Ritchie in 1973 for better portability (with exceptions to the kernel and I/O)\n",
    "\n",
    "**Linux Kernel**: [Linus Torvalds(林纳斯·托瓦兹)](https://baike.baidu.com/item/林纳斯·本纳第克特·托瓦兹/1034429?fromtitle=Linus%20Torvalds&fromid=9336769&fr=aladdin), a student at University of Helsinki began working on his own operating system, which became the \"Linux Kernel\", 1991\n",
    "\n",
    "* Linus released his **kernel** for `free download` and helped further developmen\n",
    "\n",
    "   * Linux as the kernel only, applications on top of the kernel were still missing\n",
    "\n",
    "**Linux System**: Linux kernel + `software`\n",
    "\n",
    "* `GNU/Linux(Linux)`: Linux kernel + software from the GNU project released under the `GNU Public License (GPL)`:Free to use,\n",
    "\n",
    "   * The GNU Project by Richard Stallman started in 1983 Creating a “complete Unix-compatible software system” with entirely free software\n",
    "\n",
    "It appears in many different architectures, from mainframes to **server** to **desktop** to **mobile** and on a staggeringly **wide** variety of hardware."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.2 Linux is for everyone\n",
    "\n",
    "\n",
    "#### 1.2.1 <b style=\"color:blue\">Linux is everywhere</b>\n",
    "\n",
    "* **Linux** powers 100% of the world’s **supercomputers**, \n",
    "\n",
    "* most of the **servers** powering the Internet, the majority of financial trades worldwide  \n",
    "\n",
    "* over billion **Android** and Embeed devices. \n",
    "\n",
    "\n",
    "#### 1.2.2 <b style=\"color:blue\">Linux is important for engineer and scientiste</b>\n",
    "\n",
    "**Linux is the preferred platform for scientific computing**\n",
    "\n",
    "Linux is also open source, which allows users to peer into its inner workings.\n",
    "\n",
    "Download stats across **all packages** on PyPI: \n",
    "\n",
    "* https://pypistats.org/packages/__all__\n",
    "\n",
    "The download proportion of **Linux >90%**\n",
    "\n",
    "![pypi-os](./img/linux/pypi-os.jpg)\n",
    "\n",
    "Let us to get the PyPI downloads by operating system  of packages with `pypistats`  \n",
    "\n",
    "```\n",
    ">sudo -H python3 -m pip install pypistats\n",
    "```\n",
    "```\n",
    ">pypistats system  package-name\n",
    "```\n",
    "\n",
    "**The PyPI downloads by operating system**\n",
    "\n",
    "**SciPy packages**："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "| category | percent | downloads  |\n",
      "|----------|--------:|-----------:|\n",
      "| Linux    |  88.45% | 83,306,735 |\n",
      "| Windows  |   5.08% |  4,785,241 |\n",
      "| null     |   4.42% |  4,163,280 |\n",
      "| Darwin   |   2.04% |  1,917,518 |\n",
      "| other    |   0.01% |      9,877 |\n",
      "| Total    |         | 94,182,651 |\n",
      "\n",
      "Date range: 2020-11-17 - 2021-05-16\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!pypistats system matplotlib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**CoolProp packages**:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "| category | percent | downloads |\n",
      "|----------|--------:|----------:|\n",
      "| Linux    |  61.95% |    42,594 |\n",
      "| null     |  22.78% |    15,664 |\n",
      "| Windows  |  12.97% |     8,917 |\n",
      "| Darwin   |   2.29% |     1,573 |\n",
      "| other    |   0.01% |         9 |\n",
      "| Total    |         |    68,757 |\n",
      "\n",
      "Date range: 2020-11-17 - 2021-05-16\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!pypistats system coolprop"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For engineer and scientist\n",
    "\n",
    "* The **maximum** proportion of the operating system is **Linux.** \n",
    "\n",
    "* The **proportion** of using Linux operating system was **higher than** Windows and others.\n",
    "\n",
    "**Linux is important for engineer and scientist!**\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.3 Linux System Architecture\n",
    "\n",
    "The Linux system basically works on 4 layers. See the below diagram, shows the layers of of the Linux system architecture.\n",
    "\n",
    "![Architecture-of-Linux](./img/linux/Architecture-of-Linux.png)\n",
    "\n",
    "\n",
    "* **Hardware** − Hardware consists of all physical devices attached to the System. For example: Hard disk drive, RAM, Motherboard, CPU etc.\n",
    "\n",
    "* **Kernel** − Kernel is the core component for any (Linux) operating system which directly interacts with the hardware.\n",
    "\n",
    "* **Shell** − Shell is the interface which takes input from Users and sends instructions to the Kernel, Also takes the output from Kernel and send the result back to output shell.\n",
    "\n",
    "* **Applications** − These are the utility programs which runs on Shell. This can be any application like Your web browser, media player, text editor etc\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2 Linux Distributions\n",
    "\n",
    "* **Essential components**: Linux kernel + GNU system utilities + installation scripts + management utilities etc.\n",
    "\n",
    "* Many software vendors release their own packages, known as `distributions`\n",
    "\n",
    "  * Debian, [Ubuntu](https://www.ubuntu.com/), Linux Mint,[Ubuntukylin](http://www.ubuntukylin.com/)\n",
    "  \n",
    "  * Red Hat,[Fedora](https://getfedora.org/en/), CentOS, Scientific Linux\n",
    " \n",
    "  * **Mobile** OS: [Android](https://en.wikipedia.org/wiki/Android_(operating_system))(Google),[Tizen](https://www.tizen.org/)(The Linux Foundation)\n",
    "\n",
    "**[DistroWatch](https://distrowatch.com/)**\n",
    "\n",
    "DistroWatch is a website dedicated to talking about, reviewing and keeping up to date with open source operating systems. \n",
    "\n",
    "This site particularly focuses on `Linux distributions` and flavours of BSD, though other open source operating systems are sometimes discussed.\n",
    "\n",
    "## 3 Desktop Environment\n",
    "\n",
    "Linux distributions offer a variety of **`desktop environment`**：\n",
    "\n",
    "**GNOME,KDE,MATE,Xfce**\n",
    "\n",
    "*  MATE and Xfce are the more **lightweigh** desktop environments.\n",
    "\n",
    "![Linux-desktop](./img/linux/Linux-desktop.jpg)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "## 5 Ubuntu\n",
    "\n",
    "[Ubuntu](https://www.ubuntu.com/) is a free and open-source operating system and [Linux](https://en.wikipedia.org/wiki/Linux) distribution based on [Debian](https://www.debian.org/).\n",
    "\n",
    "Mark Shuttleworth(马克·沙特尔沃思) led a team of developers to establish Ubuntu.\n",
    "\n",
    "Ubuntu is offered in three official editions:  \n",
    "\n",
    "* <b style=\"color:blue\">Ubuntu Desktop</b> for personal computers,  \n",
    "\n",
    "* <b style=\"color:blue\">Ubuntu Server</b> for servers and the cloud \n",
    "\n",
    "* <b style=\"color:blue\">Ubuntu Core</b> for Internet of things devices and robots.\n",
    "\n",
    "\n",
    "The first official Ubuntu release — Version 4.10, codenamed the ‘Warty Warthog(长疣的疣猪)’ — was launched in October 2004\n",
    "\n",
    "* **New releases** of Ubuntu occur every **6** months. \n",
    "\n",
    "* The **long-term support (LTS)** releases occur every **2**\n",
    "\n",
    "  * The most recent LTS is `20.04 LTS` ,supported for ten years. \n",
    "\n",
    ">Ubuntu is named after the Southern African philosophy of ubuntu (literally, 'human-ness'), which Canonical suggests can be loosely translated as <b style=\"color:blue\">humanity to others(善待他人)</b> or  <b style=\"color:blue\">I am what I am because of who we all are(我存在,因为我们存在)</b>\n",
    "> \n",
    ">The African philosophy of “ubuntu” — a concept in which your sense of self is shaped by your relationships with other people. It’s a way of living that begins with the premise that “I am” only because “we are.” \n",
    ">\n",
    "><font style=\"color:blue\">I am thinking, therefore I am(我思故我在)</font> - Rene Descartes(勒内·笛卡尔)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[优麒麟（Ubuntu Kylin）](http://www.ubuntukylin.com/)\n",
    "\n",
    "由中国 CCN（由CSIP、Canonical、NUDT三方联合组建）开源创新联合实验室与天津麒麟信息技术有限公司主导开发的全球开源项目，其宗旨是通过研发用户友好的桌面环境以及特定需求的应用软件，为全球 Linux 桌面用户带来非凡的全新体验！\n",
    "优麒麟操作系统是 Ubuntu 官方衍生版，得到来自 Debian、Ubuntu、Mate、LUPA 等国际社区及众多国内外社区爱好者的广泛参与和热情支持\n",
    "\n",
    "[银河麒麟](http://www.kylinos.cn/) \n",
    "\n",
    "银河麒麟操作系统及相关衍生产品已成功应用于国防、政务、电力、金融、能源、教育等行业，基于银河麒麟操作系统和飞腾CPU的自主可控产品及方案已经成为我国自主安全可控信息系统的核心技术应用。\n",
    "\n",
    "![UbuntuKylin](./img/linux/ubuntukylin.jpg)\n",
    "\n",
    "\n",
    "\n",
    "[Raspberry Pi](https://www.raspberrypi.org/)\n",
    "\n",
    "Our mission is to put the power of computing and digital making into the hands of people all over the world. We do this so that more people are able to harness the power of computing and digital technologies for work, to solve problems that matter to them, and to express themselves creatively.\n",
    "\n",
    "**Raspbian** is our official operating system for all models of the Raspberry Pi. Download it here, or use NOOBS, our easy installer for Raspbian and more.\n",
    "\n",
    "![raspberryp](./img/linux/raspberrypi.jpg)\n",
    "\n",
    "\n",
    "**Ubuntu on Windows**\n",
    "\n",
    "* [Install Windows Subsystem for Linux (WSL) on Windows 10(Chinese)](https://docs.microsoft.com/zh-cn/windows/wsl/install-win10)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6 Using Terminal\n",
    "\n",
    "Programmers use **\"Terminal\"** to issue commands, instead of the graphical user interface\n",
    "\n",
    "To launch a Terminal in Debian/Ubuntu:\n",
    "\n",
    "* Press `Ctrl+Alt+T`\n",
    "\n",
    "* `Right-click` inside a folder/desktop, then,click `open a terminal`\n",
    "\n",
    "A Terminal displays a command prompt ending with a `\"$\"` sign, in the form of:\n",
    "\n",
    "`\"Username@ComputerName:CurrentDirectory$\"`\n",
    "\n",
    "You can enter commands after the command prompt. For example, enter \"`ls`\" to list the contents of the current working directory, e.g.,\n",
    "\n",
    "```bash\n",
    "<prompt>$ls\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!ls"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7 Linux File System\n",
    "\n",
    "Linux supports numerous file systems, but common choices for the system disk on a block device include the **`ext*`** family (ext2, ext3 and ext4), XFS, JFS, and btrfs.\n",
    "\n",
    "**Ext4**(fourth extended filesystem ) is the default file system on most Linux distributions\n",
    "\n",
    ">In computing, **a file system** controls how data is stored and retrieved. \n",
    "\n",
    ">Without a file system, data placed in a storage medium would be one large body of data with no way to tell where one piece of data stops and the next begins. By separating the data into pieces and giving each piece a name, the data is easily isolated and identified.\n",
    "\n",
    ">Taking its name from the way paper-based data management system is named,\n",
    "> * **file**： each group of data \n",
    "> * **file system**： the structure and logic rules used to manage the groups of data and their names  \n",
    "\n",
    "\n",
    "### 7.1 Files\n",
    "\n",
    "A simple description of the UNIX system, also applicable to Linux, is this:\n",
    "\n",
    "* **\"On a UNIX system, everything is a file; if something is not a file, it is a process.\"**\n",
    "\n",
    "**Sorts of files** \n",
    "\n",
    "Most files are just files, called **regular files**(普通文件）： \n",
    "\n",
    "* they contain normal data,executable files or programs, input for or output from a program and so on.\n",
    "\n",
    "While it is reasonably safe to suppose that **everything you encounter on a Linux system is a file**, there are some exceptions.\n",
    "\n",
    "* **Directories** files that are lists of other files.\n",
    "\n",
    "* **Special** files: the mechanism used for input and output. Most special files are in `/dev`\n",
    "\n",
    "* **Links** : a system to make a file or directory visible in multiple parts of the system's file tree. \n",
    "\n",
    "* **(Domain) sockets**: a special file type, similar to TCP/IP sockets, providing inter-process networking protected by the file system's access control.\n",
    "\n",
    "* **Named pipes:** act more or less like sockets and form a way for processes to communicate with each other, without using network socket semantics.\n",
    "\n",
    "\n",
    "### 7.2 File Directory Structure\n",
    "\n",
    "* All`files` are arranged in `directories`.\n",
    "\n",
    "* These `directores` are organized into the `file system`\n",
    "\n",
    "![Linux File System](./img/linux/linux-file-system.jpg)\n",
    "\n",
    "![dir](./img/linux/linux-dir.jpg)\n",
    "\n",
    "**Important Directories**\n",
    "\n",
    "* <b style=\"color:blue\">/</b>: the **root** directory\n",
    "\n",
    "* <b style=\"color:blue\">/boot</b>: contains `bootable kernel and bootloader`（可引导内核和引导加载程序）\n",
    "\n",
    "* <b style=\"color:blue\">/home</b>:  contains home directories of **all users**.（所有用户的主目录)\n",
    "\n",
    "  * This is the directory where you are at when you login to a Linux/UNIX system.\n",
    "\n",
    "* <b style=\"color:blue\">/lib,/lib64</b>: contains **libraries** that are essential for system operation, available for use by all users.\n",
    "\n",
    "* <b style=\"color:blue\">/bin</b>:  contains files that are essential for system operation, available for use by all users.\n",
    "\n",
    "* <b style=\"color:blue\">/mnt</b>: A convenient point to `temporarily mount devices`, such as CD-ROMs and flash memory sticks.\n",
    "\n",
    "* <b style=\"color:blue\">/etc</b>:  contains various system **configurations**\n",
    "\n",
    "* <b style=\"color:blue\">/dev</b>:  contains various **devices** such as hard disk, CD-ROM drive etc(**In Linux, everything is a file**)\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "![dev](./img/linux/linux-dev.jpg)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 7.2.1 Linux: HOME Directory\n",
    "\n",
    "The **/home/** contains home directories of all users.\n",
    "\n",
    "This is the directory where you are at when you **login** to a Linux/UNIX system.\n",
    "\n",
    "* For regular users, it is typically called <b style=\"color:blue\">/home/username</b> for Ubuntu\n",
    "* The home directory for superuser 'root' is `/root`.\n",
    "* System users do not have home directory.\n",
    "    \n",
    "Consider, a regular user account **\"user1\"**. \n",
    "\n",
    "* He can store his personal files and directories in the directory <b style=\"color:blue\">/home/user1</b>.\n",
    "\n",
    "* He can't save files outside his user directory and does not have access to directories of other users.    \n",
    "  * For instance, he cannot access directory <b style=\"color:blue\">/home/user2</b> of another user account\"user2\".\n",
    "\n",
    "When **user1** login the Linux operating system, the <b style=\"color:blue\">/home/user1</b> is the default **working directory**. \n",
    "\n",
    "```bash\n",
    "$pwd\n",
    "```\n",
    "* `pwd` stands for `Print Working Directory` and is shell built-in command. It prints the  complete path of the working directory with the  path starting from root **(/)**. \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](./img/linux/linux-wd.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.3 File Path\n",
    "\n",
    "File Path(Definition): position/address in the `directory tree`\n",
    "\n",
    "**Absolute path**\n",
    "\n",
    "`Uniquely` defined and does **NOT depend on the current path**\n",
    "\n",
    "An absolute path begins from the **root** directory. That is, it starts with a `\"/\"` followed by all the sub-directories, separated with `\"/\"` leading to the file, e.g., `\"/usr/lib/jvm/jdk1.7.0_07/bin/\".`\n",
    "\n",
    "**Relative path**\n",
    "\n",
    "A relative path is relative to the so-called **current working directory**. A relative path does NOT begin with \"/\" or \"~\".\n",
    "\n",
    "For example,\n",
    "\n",
    "if the current working directory is `\"/usr/lib/jvm/\"`, then the relative pathname \"`jdk1.7.0_07/bin/\" `refers to `\"/usr/lib/jvm/jdk1.7.0_07/bin/\".`\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Change Directory `\"cd\"` Command**\n",
    "\n",
    "To change the current working directory, issue command `\"cd <new-pathname>\"`.\n",
    "\n",
    "You can specify new-pathname in two ways: `absolute` or `relative`. \n",
    "\n",
    "As explained earlier, an absolute path begins with a `\"/\" (root directory) or \"~\"` (home directory); \n",
    "\n",
    "whereas a relative path is relative to the `current working directory` and does NOT begin with \"/\" or \"~\". For example,\n",
    "\n",
    "```bash\n",
    "cd /                // Change directory (absolute) to the root\n",
    "cd /usr/local       // Change directory (absolute) to \"/usr/local\"\n",
    "cd demo            // Change directory (relative) to demo of the current directory\n",
    "cd demo/bin    // Change directory (relative) to demo/bin of the current directory\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Root (/), Home (~), Parent (..), Current (.) Previous (-) Directory**\n",
    "\n",
    "*  \"/\" to denote the root; \n",
    "\n",
    "* \"~\" to refer to your home directory; \n",
    "\n",
    "* \"..\" (double-dot) to refer to the parent directory; * \n",
    "\n",
    "* \".\" (single-dot) to refer to the current directory;\n",
    "\n",
    "*  \"-\" (dash) to refer to the previous directory.\n",
    "\n",
    "For example,\n",
    "\n",
    "\n",
    "```bash\n",
    "cd ~            // Change directory to the home directory of the current user\n",
    "cd              // same as above, default for \"cd\" is home directory\n",
    "cd ~/Documents  // Change directory to the sub-directory \"Documents\" of the home directory of the current user\n",
    "cd ..           // Change directory to the parent directory of the current working directory\n",
    "cd -            // Change directory to the previous working directory (OLDPWD)\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "For example,we open the terminal in root,then\n",
    "\n",
    "![](./img/linux/linux-path-1.jpg)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**List Directory `\"ls\"` Command**\n",
    "\n",
    "You can use command `ls` to list the contents of the current working directory, e.g.,\n",
    "\n",
    "List contents of current working directory in short format\n",
    " \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!ls"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "List in \"long\" format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!ls -l"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](./img/linux/ls.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4 Linux is Case Sensitive\n",
    "\n",
    "All names are **case sensitive**\n",
    "\n",
    "*  Commands, variables, files etc.\n",
    "\n",
    "Example: `MyFile.txt, myfile.txt, MYFILE.TXT` are three different files in Linux\n",
    "\n",
    "\n",
    "### 7.5 Linux File Permission\n",
    "\n",
    "Designed as the multi **user** environment, the **access restriction** of files to other users on the system is embedded.\n",
    "\n",
    "![](./img/UnixFileLongFormat.png)\n",
    "\n",
    "Three types of **file permission**\n",
    "\n",
    "* Read (r)\n",
    "\n",
    "* Write (w)\n",
    "\n",
    "* Execute (x)\n",
    "\n",
    "Three types of **user**\n",
    "\n",
    "* User (u) (owner)\n",
    "\n",
    "* Group (g) (group members)\n",
    "\n",
    "* World (o) (everyone else on the system)\n",
    "\n",
    "Each file in Linux has the following attributes:\n",
    "\n",
    "* `Owner permissions`: determine what actions the owner of the file can perform on a file\n",
    "\n",
    "* `Group permissions`: determine what actions a user, who is a member of the group that a file belongs to, can perform on a file\n",
    "\n",
    "* `Other(world) permissions`: indicate what action all other users can perform on a file\n",
    "\n",
    "\n",
    "The `-l`option to **ls** displays the file type,using the **first column** indicates the type of a **file/dir/link**\n",
    "\n",
    "* `d`: for directory\n",
    "\n",
    "* `l`: for `symbolic link`(符号链接(软链接):将路径名链接到一个文件)\n",
    "\n",
    "* `-` for normal file\n",
    "\n",
    "> **A symbolic link** is a `file` that links to another file or directory using its path. you can think of a symbolic link as `a shortcut` to a file or directory (folder). symbolic links may be used in the command line, or in a script or another program.\n",
    "\n",
    "\n",
    "![UnixFileLongFormat.png](./img/linux/UnixFileLongFormat.png)\n",
    "\n",
    "![linux-file-permissions.jpg](./img/linux/linux-file-permission.jpg)\n",
    "\n",
    "### 7.6 Changing File Permission\n",
    "\n",
    "**chmod** is a *NIX command to change permissions on a file\n",
    "\n",
    "Usage: \n",
    "```bash\n",
    "chmod <option> <permissions> <file or directory name>\n",
    "```\n",
    "**chmod in Symbolic Mode:**\n",
    "\n",
    "|Chmod| operator Description|\n",
    "|:-------:|:--------:|\n",
    "|+ |Adds the designated permission(s) to a file or directory|\n",
    "|- |Removes the designated permission(s) from a file or directory|\n",
    "|= |Sets the designated permission(s) and removes other permission(s|\n",
    "\n",
    "```bash\n",
    "$chmod u-x filename\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](./img/linux/linux-hello.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 8  Applications and Utilities\n",
    "\n",
    "* **LibreOffice**: The default Ubuntu's productivity suite, which is a variant of OpenOffice (currently owned by Apache). It includes:\n",
    "  \n",
    "  * Writer: word processor, similar to Microsoft Word.\n",
    "  * Calc: spreadsheet, similar to Microsoft Excel.\n",
    "  * Impresss: Presentation program, similar to Microsoft Powerpoint.\n",
    "  * Math: Math formula editor.\n",
    "  * Draw: Graphics application for creating images.\n",
    "  * Base: Database application, similar to Microsoft Access.\n",
    "\n",
    "* **Dia**: Technical diagram drawing editor, similar to Microsoft Visio.\n",
    "\n",
    "* **gedit** Text Editor: The GNU gedit is the default text editor in Ubuntu. [TODO] more.\n",
    "\n",
    "* **Screenshot**: Press `PrintScreen` key to capture the entire screen; `alt+PrintScreen` key to capture the current window. The images are captured in PNG. Alternatively, use the dash to search for `\"Screenshot\"`. You can set the area of screenshot.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 9 APT for Managing Software\n",
    "\n",
    "Ubuntu adopts Debian's **Advanced Packaging Tool (APT)** for software package management of `\".deb\"` package.\n",
    "\n",
    ">Other Linux distros, such as Red Hat, uses RPM Package Manager.\n",
    "\n",
    "APT can properly handle the dependencies. It automatically finds and downloads all the dependencies of the packages to be installed. It can also resume installation after an interruption.\n",
    "\n",
    "The  apt includes sub-commands such as `list, search, show, update, install, remove, upgrade, full-upgrade, edit-source`.\n",
    "\n",
    "### 9.1  Software sources\n",
    " \n",
    "`APT` keeps a list of software sources on your computer in a file at `/etc/apt/sources.list`.\n",
    "\n",
    "Before installing software, you **should update your package list** with apt update:\n",
    "\n",
    "```\n",
    "sudo apt update\n",
    "```\n",
    "\n",
    "> **Superuser 'root' and Superuser-do 'sudo'**\n",
    "> \n",
    "> **Superuser root**\n",
    "> \n",
    "> In Linux, the default **superuser** is called `root`, which can do everything and anything, including destructive tasks. \n",
    "> \n",
    "> Doing regular tasks (such as program development) with root can be dangerous, as root could remove important system files and destroy your > system. Hence, it is strongly recommended to do regular work with a regular user instead of superuser.\n",
    "> \n",
    "> However, at times, you need the **superuser privilege to perform a task**, such as install a new software and writing to a system > directory. You can do it in two ways: **sudo (superuser-do)** \n",
    "> \n",
    "> **sudo <command>**\n",
    "> \n",
    "> An authorized user can run a command with `superuser privilege by prefixing it with 'sudo'` (superuser-do).\n",
    "> \n",
    "> * The list of users authorized to do 'sudo' is kept in /etc/sudoers (called sudo list).\n",
    "> \n",
    "> When you issue **sudo <command>**, the system will prompt for **password** Reply with the CURRENT login-user's password. \n",
    "\n",
    "### 9.2 Installing a package with APT\n",
    "\n",
    "Installing a package with APT\n",
    "\n",
    "```\n",
    "sudo apt install git\n",
    "```\n",
    "\n",
    "### 9.3 Uninstalling a package with APT\n",
    "\n",
    "* Remove\n",
    "\n",
    "  You can uninstall a package with `apt remove`:\n",
    "```\n",
    "sudo apt remove git\n",
    "```\n",
    "\n",
    "* Purge\n",
    "\n",
    "  You can also choose to `completely remove the package and its associated configuration files` with `apt purge`\n",
    "```\n",
    "sudo apt purge git\n",
    "```\n",
    "\n",
    "### 9.4 Upgrading existing software\n",
    "\n",
    "If software updates are available, you can get the updates with \n",
    "\n",
    "```\n",
    "sudo apt update \n",
    "```\n",
    "\n",
    "install the updates with \n",
    "\n",
    "```\n",
    "sudo apt upgrade\n",
    "```\n",
    "\n",
    "which will upgrade all of your packages.\n",
    "\n",
    "To upgrade a `specific` package, without upgrading all the other out-of-date packages at the same time, you can use \n",
    "```\n",
    "sudo apt install somepackage\n",
    "```\n",
    "which may be useful if you're low on disk space or you have limited download bandwidth.\n",
    "\n",
    "### 9.5 Searching for software\n",
    "You can search the archives for a package with a given keyword with `apt search`\n",
    "\n",
    "```\n",
    "apt search python3-pip\n",
    "```\n",
    "You can view more information about a package before installing it with  `apt show`\n",
    "\n",
    "```\n",
    "apt show  python3-pip\n",
    "```\n",
    "\n",
    "###  9.6 Installing a package with dpkg\n",
    "\n",
    "* `dpkg:` The dpkg (Debian Package Manager) is the low level tool for installing, removing and providing information about '.deb' packages.\n",
    "\n",
    "```bash\n",
    "sudo dpkg -i vscode_filename.deb\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Reference\n",
    "\n",
    "* [How to install and Get Started with Ubuntu Desktop 16.04LTS](http://www3.ntu.edu.sg/home/ehchua/programming/howto/Ubuntu_HowTo.html)\n",
    "\n",
    "* edX: Introduction to Linux https://www.edx.org/course/introduction-to-linux\n",
    "\n",
    "* Ubuntu https://www.ubuntu.com/\n",
    "\n",
    "  * Ubuntukylin https://www.ubuntukylin.com/\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.7"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  },
  "widgets": {
   "state": {},
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
